package com.fz.controller.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fz.aop.login.AnonymousAccess;
import com.fz.common.ResponseEntity;
import com.fz.beans.PageBeans;
import com.fz.dto.system.job.JobAdd;
import com.fz.dto.system.job.JobQuery;
import com.fz.dto.system.job.JobUpd;
import com.fz.service.system.JobService;
import com.fz.vo.system.job.JobVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiSort;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "岗位管理")
@RequestMapping("/job")
@ApiSort(value = 6)
@SuppressWarnings("unchecked")
public class JobController{

    @Resource
    private JobService jobService;

    @GetMapping("/findJobList")
    @ApiOperation(value = "分页查询岗位列表")
    @ApiOperationSupport(order = 1)
    @AnonymousAccess
    public ResponseEntity<IPage<JobVo>> findJobList(JobQuery jobQuery, PageBeans pageBeans) throws Exception{
        return jobService.findJobList(jobQuery, pageBeans.getPageNum(), pageBeans.getPageSize());
    }

    @PostMapping("/addJob")
    @ApiOperation(value = "新增岗位")
    @ApiOperationSupport(order = 2)
    @AnonymousAccess
    public ResponseEntity addJob(@RequestBody JobAdd jobAdd) throws Exception{
        return jobService.addJob(jobAdd);
    }

    @PostMapping("/updateJob")
    @ApiOperation(value = "修改岗位")
    @ApiOperationSupport(order = 3)
    @AnonymousAccess
    public ResponseEntity updateJob(@RequestBody JobUpd jobUpd) throws Exception{
        return jobService.updateJob(jobUpd);
    }
}
